#ifndef MSG_H
#define MSG_H

#include "../hostdep/stdint.h"

static const unsigned int HEADER_SIZE = 4;

typedef enum {MSG_TYPE_CONTROL = 0, MSG_TYPE_DATA = 1} message_type;
typedef enum {MSG_DELIVERY_SYNC = 0, MSG_DELIVERY_ASYNC = 1} message_delivery;
typedef enum {MSG_SCOPE_GLOBAL = 0, MSG_SCOPE_DEVICE_SPECIFIC = 1}
  message_scope; 
typedef enum {MSG_DIRECTION_REQUEST = 0, MSG_DIRECTION_RESPONSE = 1}
  message_direction;

void set_message_id(unsigned char* message, uint32_t message_id);

void set_device_id(unsigned char* message, uint16_t device_id);

void set_message_info(unsigned char* message, message_type type,
  message_delivery delivery, message_scope scope, message_direction direction,
  uint16_t msg_number);

uint32_t get_message_id(unsigned char* message);

uint16_t get_device_id(unsigned char* message);

message_type get_message_type(unsigned char* message); message_delivery
get_message_delivery(unsigned char* message); message_scope
get_message_scope(unsigned char* message); message_direction
get_message_direction(unsigned char* message); uint16_t
get_message_number(unsigned char* message);

#endif
